package cn.iocoder.yudao.module.handguard.service.notification;


import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi;
import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.HashMap;
import java.util.Map;

@Service
@Validated
public class NotificationServiceImpl implements NotificationService{


    @Resource
    private NotifyMessageSendApi sendApi;

    @Override
    public boolean sendOrderNotification(String msg,String temCode, Long userId) {
        Map<String, Object> map = new HashMap<>();
        map.put("message",msg);
        NotifySendSingleToUserReqDTO reqDTO = new NotifySendSingleToUserReqDTO();
        reqDTO.setTemplateCode(temCode);
        reqDTO.setUserId(userId);
        reqDTO.setTemplateParams(map);
        Long send = sendApi.sendSingleMessageToAdmin(reqDTO);
        if (send != null) {
            return true;
        }else {
            return false;
        }
    }
}
